//
//  ViewController.m
//  26_Mansory
//
//  Created by 徐昊 on 16/8/18.
//  Copyright © 2016年 徐昊. All rights reserved.
//

#import "ViewController.h"
#import "Masonry.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    // 1> 添加红色视图
    // 使用 Mansory, 不用给初始frame
    UIView *view = [UIView new];
    view.backgroundColor = [UIColor redColor];
    // 添加约束前, 需要把视图添加到父视图上
    [self.view addSubview:view];
    // 设置该视图的约束
    [view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
        make.top.mas_equalTo(0);
    }];
    // 2. 添加蓝色视图, 宽高各100, 居中显示
    UIView *view1 = [UIView new];
    view1.backgroundColor = [UIColor blueColor];
    [self.view addSubview:view1];
    [view1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(100);
//        make.height.mas_equalTo(100);
        make.centerX.mas_equalTo(0);
        make.centerY.mas_equalTo(0);
        make.height.mas_equalTo(self.view.mas_height).multipliedBy(0.5);
    }];
    // 3. 添加 黄色视图, 宽高与蓝色相同, 与蓝色相距10
    UIView *yellowView = [UIView new];
    yellowView.backgroundColor = [UIColor yellowColor];
    [self.view addSubview:yellowView];
    [yellowView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.mas_equalTo(view1);
        make.top.mas_equalTo(view1.mas_bottom).mas_offset(10);
        make.width.centerX.height.mas_equalTo(view1);
    }];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
